<?php
if ( function_exists( 'add_theme_support' ) ) {
    add_theme_support( 'post-thumbnails' );
    add_image_size( 'banner', 593, 366, true );
    add_image_size( 'histoire', 560, 414, true );
    add_image_size( 'transmission', 578, 434, true );
    add_image_size( 'sticky', 478, 665, true );
}
       if(function_exists('register_sidebar')) {
       register_sidebar(array('name' => 'sidebar',
       'before_title' => '<h2>',
       'after_title' => '</h2>',
       'before_widget' => "<div class='boxes'>",
       'after_widget' => '</div>',
        ));
      };
       
    // Do shortcode
 add_filter('the_content', 'do_shortcode', 11);
// Register for using menu
add_theme_support('menus');
// Add class to active menu
function active_menu($output) {
  $output = preg_replace('/current-menu-item/', 'active current-menu-item', $output, 1);
  return $output;
}
add_filter('wp_nav_menu', 'active_menu');

function active_menu_parent($output) {
  $output = preg_replace('/current-menu-parent/', 'active current-menu-parent', $output, 1);
  return $output;
}
//Add first/last class in menu item
function add_first_and_last($output) {
  $output = preg_replace('/class="(\w*\s)?menu-item/', 'class="$1first home menu-item', $output, 1);
  $pos=strripos($output, 'class="menu-item');
  $len=strlen('class="menu-item');
  $rep='class="last menu-item';
  if(strripos($output, ' menu-item ')>$pos){
   $pos=strripos($output, ' menu-item ');
   $len=strlen(' menu-item ');
   $rep=' last menu-item ';
  }
  $output = substr_replace($output, $rep, $pos, $len);
  return $output;
}
add_filter('wp_nav_menu', 'add_first_and_last');
    
    
 ?>